package com.own.business.message.center.entity.vo;

import com.own.business.message.center.entity.po.MessageCenterGroupChild;
import com.own.component.common.base.entity.vo.BaseSortVo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * MessageCenterGroupChildVo
 *
 * @author chenxueli
 * @date 2023-11-13 18:17:40
 */
@Schema(title = "消息中心分组子级" + ConstantBeanSuffix.VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class MessageCenterGroupChildVo extends BaseSortVo<MessageCenterGroupChild> implements Serializable {

    @Schema(title = "分组id")
    private Long groupId;

    @Schema(title = "分组key（冗余）")
    private String groupKey;

    @Schema(title = "消息名称")
    private String name;

    @Schema(title = "消息key")
    private String messageKey;

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public MessageCenterGroupChildVo(@NonNull MessageCenterGroupChild entity) {
        super(entity);
        this.groupId = entity.getFkGroupId();
        this.groupKey = entity.getGroupKey();
        this.name = entity.getName();
        this.messageKey = entity.getMessageKey();
    }

    /**
     * 转po对象
     *
     * @param entity 原对象
     * @return po对象
     */
    @Override
    public MessageCenterGroupChild toPo(MessageCenterGroupChild entity) {
        if (entity == null) {
            entity = new MessageCenterGroupChild();
        }
        entity.setFkGroupId(this.groupId);
        entity.setGroupKey(this.groupKey);
        entity.setName(this.name);
        entity.setMessageKey(this.messageKey);
        return super.toPo(entity);
    }

}
